﻿using PlaceOrder_Core.Services.Instances;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlaceOrder_Core.Helper
{
    public class DeliverySpeedConverter
    {
        public static string ConvertToSpeed(string originInfo)
        {
            return originInfo;
            DateTime time;
            string formattedDate;
            // Helper method to find the next working day
            DateTime FindNextWorkingDay(DateTime startDate)
            {
                DateTime currentDate = startDate;

                // Check if the current date is a holiday or weekend, and move to the next day if it is
                //while (DailyData.Holidays1.Contains(DateOnly.FromDateTime(currentDate)) || currentDate.DayOfWeek == DayOfWeek.Saturday || currentDate.DayOfWeek == DayOfWeek.Sunday)
                //{
                //    currentDate = currentDate.AddDays(1);
                //}
                while (DailyData.Holidays1.Contains(currentDate.Date) ||
      currentDate.DayOfWeek == DayOfWeek.Saturday ||
      currentDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    currentDate = currentDate.AddDays(1);
                }
                return currentDate;
            }

            switch (originInfo)
            {
                case "明天+0":
                    time = DateTime.Now.AddDays(1);
                    time = FindNextWorkingDay(time);
                    formattedDate = time.ToString("M月d日", CultureInfo.InvariantCulture);
                    return formattedDate + "+0";

                case "T+0":
                case "+0":
                    time = DateTime.Now;
                    time = FindNextWorkingDay(time);
                    formattedDate = time.ToString("M月d日", CultureInfo.InvariantCulture);
                    return formattedDate + "+0";

                case "T+1":
                case "+1":
                    time = DateTime.Now.AddDays(1);
                    time = FindNextWorkingDay(time);
                    formattedDate = time.ToString("M月d日", CultureInfo.InvariantCulture);
                    return formattedDate + "+1";

                default:
                    return originInfo;
            }


        }
    }
}
